package org.yx.service.sqcm.view_hold_definition;

import org.dbist.dml.Page;
import org.dbist.dml.Query;
import org.yx.models.SqcmHldDef;
import org.yx.utils.BaseService;

import com.xiaoleilu.hutool.util.StrUtil;

/**
 * 查询品质冻结定义
 * 
 * @author zxw
 * @since 2019/03/28
 **/
public class SqcmViewHoldDefinitionService extends BaseService {
	public SqcmViewHoldDefinitionOut viewHoldDefinition(SqcmViewHoldDefinitionIn in) throws Exception {
		Query query = new Query(in.getPageIndex(), in.getPageSize());
		query.addFilter("orgCode", in.getUserOrgCode());
		if (StrUtil.isNotBlank(in.getHoldNo())) {
			query.addFilter("holdNo", in.getHoldNo());
		}
		if (StrUtil.isNotBlank(in.getHoldCode())) {
			query.addFilter("holdCode", in.getHoldCode());
		}
		if (StrUtil.isNotBlank(in.getHoldUser())) {
			query.addFilter("holdUser", in.getHoldUser());
		}

		Page<SqcmHldDef> holdPage = selectPage(SqcmHldDef.class, query);

		SqcmViewHoldDefinitionOut out = new SqcmViewHoldDefinitionOut();
		out.setHoldList(holdPage.getList());
		out.setTotal(holdPage.getTotalSize());

		return out;
	}
}